package com.baor.web.controller.order;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baor.common.annotation.Log;
import com.baor.common.core.controller.BaseController;
import com.baor.common.core.domain.AjaxResult;
import com.baor.common.enums.BusinessType;
import com.baor.order.domain.TShopaddress;
import com.baor.order.service.ITShopaddressService;
import com.baor.common.utils.poi.ExcelUtil;
import com.baor.common.core.page.TableDataInfo;

/**
 * 商家地址Controller
 * 
 * @author ruoyi
 * @date 2025-07-18
 */
@RestController
@RequestMapping("/order/shopaddress")
public class TShopaddressController extends BaseController
{
    @Autowired
    private ITShopaddressService tShopaddressService;

    /**
     * 查询商家地址列表
     */

    @GetMapping("/list")
    public TableDataInfo list(TShopaddress tShopaddress)
    {
        startPage();
        List<TShopaddress> list = tShopaddressService.selectTShopaddressList(tShopaddress);
        return getDataTable(list);
    }

    /**
     * 导出商家地址列表
     */
    @PreAuthorize("@ss.hasPermi('order:shopaddress:export')")
    @Log(title = "商家地址", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TShopaddress tShopaddress)
    {
        List<TShopaddress> list = tShopaddressService.selectTShopaddressList(tShopaddress);
        ExcelUtil<TShopaddress> util = new ExcelUtil<TShopaddress>(TShopaddress.class);
        util.exportExcel(response, list, "商家地址数据");
    }

    /**
     * 获取商家地址详细信息
     */

    @GetMapping(value = "/{shopaddressId}")
    public AjaxResult getInfo(@PathVariable("shopaddressId") Long shopaddressId)
    {
        return success(tShopaddressService.selectTShopaddressByShopaddressId(shopaddressId));
    }

    /**
     * 新增商家地址
     */

    @Log(title = "商家地址", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TShopaddress tShopaddress)
    {
        return toAjax(tShopaddressService.insertTShopaddress(tShopaddress));
    }

    /**
     * 修改商家地址
     */

    @Log(title = "商家地址", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TShopaddress tShopaddress)
    {
        return toAjax(tShopaddressService.updateTShopaddress(tShopaddress));
    }

    @PostMapping("/deleteTShopaddress")
    public AjaxResult deleteTShopaddress(@RequestBody TShopaddress tShopaddress)
    {
        return toAjax(tShopaddressService.deleteTShopaddress(tShopaddress));
    }
    /**
     * 删除商家地址
     */
    @PreAuthorize("@ss.hasPermi('order:shopaddress:remove')")
    @Log(title = "商家地址", businessType = BusinessType.DELETE)
	@DeleteMapping("/{shopaddressIds}")
    public AjaxResult remove(@PathVariable Long[] shopaddressIds)
    {
        return toAjax(tShopaddressService.deleteTShopaddressByShopaddressIds(shopaddressIds));
    }
}
